package Text3;

import java.util.*;

/*
 *@Student 张策
 */
public class Main3 {
    public static void main(String[] args) {
        Map map = new HashMap();
        map.put("no.1","zc1");
        map.put("no.2","zc2");
        map.put("no.3","zc3");
        map.put("no.4","zc4");
        map.put("no.5","zc5");
        //第一组
        System.out.println("====第一组for");
        Set keySet = map.keySet();
        for (Object o :keySet) {
            System.out.println(o+"-"+map.get(o));
        }
        System.out.println("===第一组迭代器======");
        Iterator iterator=keySet.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        //第二组
        System.out.println("====第二组for====");
        Collection values = map.values();
        for (Object o :values) {
            System.out.println(o);
        }
        System.out.println("=====第二组for=====");
        Iterator iterator1 = values.iterator();
        while (iterator1.hasNext()) {
            System.out.println(iterator1.next());
        }
        System.out.println("====第三组增强for====");
        Set entrySet = map.entrySet();
        for (Object o :entrySet) {
            Map.Entry entry=(Map.Entry)o;
            System.out.println(entry.getKey()+"="+entry.getValue());
        }
        System.out.println("====第三组迭代器====");
        Iterator iterator2 = entrySet.iterator();
        while (iterator2.hasNext()) {
            System.out.println(iterator2.next());
        }
    }
}
